<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
	<title>TravelDream Home</title>
	<h:outputStylesheet library="TdTheme" name="css/style.css"/> 	
</h:head>
<h:body>
	<h:form>  
	    <p:menubar>  
	        <p:submenu label="Inserisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="crea_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="crea_escursione.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="crea_volo.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Gestisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="cerca_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="cerca_escursioni.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="cerca_voli.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Pacchetti Preconfigurati" icon="ui-icon-document">  
	            <p:menuitem value="Crea" url="crea_pp.xhtml?faces-redirect.xhtml"/>  
	            <p:menuitem value="Gestisci" url="gestione_pp.xhtml?faces-redirect=true"/>  
	        </p:submenu>    
	  
	        <f:facet name="options">  
	            <p:commandButton value="Logout" icon="ui-icon-extlink" action="#{loginManagedBean.logout()}"/>  
	        </f:facet>  
	    </p:menubar>  
  	</h:form>  	
  	<h:form>
	<p:messages id="messaggio" showDetail="true" autoUpdate="true" closable="true" /> 
	</h:form>
	<h:panelGrid columns="1" styleClass="userTopBar">
		<p:panel>
			<h:form id="search_form">
				<h:panelGrid columns = "5">
					<h:outputLabel value="Nome hotel:" />
					<p:inputText value="#{hotelManagedBean.nome}" id="nomeInput"/>
					<h:outputLabel value="Citta:" />
					<p:inputText value="#{hotelManagedBean.luogoFruizione}" id="cittaInput"/>
					<br/>
					<p:outputLabel>Escludi pacchetti non in vendita: </p:outputLabel>
					<p:selectBooleanCheckbox value="#{hotelManagedBean.escludiNonInVendita}"/>
					<p:commandButton value="Cerca" action="#{hotelManagedBean.searchHotel()}"/>  
				</h:panelGrid>
				<p:dataTable id="searchOutput" var="n" value="#{hotelManagedBean.listaHotel}">
  						<p:column headerText="ID">
                    		<h:outputText value="#{n.id}"/>
                		</p:column>
						
						<p:column headerText="Nome">
		                    <h:outputText value="#{n.nome}"/>
		                </p:column>
		                
		                <p:column headerText="Citta">
		                    <h:outputText value="#{n.luogo}"/>
		                </p:column>
		
		                <p:column headerText="Prezzo">
		                    <h:outputText value="#{n.prezzo}"/>
		                </p:column>
		
       			        <p:column headerText="Stato" rendered="#{!hotelManagedBean.escludiNonInVendita}">
		                	<h:outputText value="In vendita" rendered="#{n.inVendita}" style="color:#00F;"/>
		                	<h:outputText value="Non in vendita" rendered="#{!n.inVendita}" style="color:#F00;" />
		                </p:column>
		                
		                <p:column>
		                	<p:commandButton value="Modifica" action="#{modificaHotelManagedBean.parametriHotel(n)}"/>
							<p:commandButton value="Elimina" action="#{hotelManagedBean.eliminaHotel(n)}"/>
		                	<p:commandButton value="Rimuovi dalla vendita" action="#{hotelManagedBean.cambioStatoVendita(n)}" rendered="#{hotelManagedBean.isInVendita(n)}"/>
							<p:commandButton value="Metti in vendita" action="#{hotelManagedBean.cambioStatoVendita(n)}" rendered="#{!hotelManagedBean.isInVendita(n)}"/>
		                </p:column>
                </p:dataTable>	
			</h:form>
		</p:panel>
	</h:panelGrid>
</h:body>
</html>
